package com.zyx.concurrentdemo.mytest.c04;

import lombok.extern.slf4j.Slf4j;

import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;

/**
 * @author Yaxi.Zhang
 * @since 2021/10/15 15:18
 */
public class ExecturosDemo {
    public static void main(String[] args) {
        ExecutorService executorService = Executors.newFixedThreadPool(6);
        for (int i = 0; i < 10; i++) {
            executorService.submit(new TaskThread("thread-" + i));
        }
    }
}

@Slf4j(topic = "c.Task")
class TaskThread extends Thread {

    private final String name;

    public TaskThread(String name) {
        this.name = name;
    }

    @Override
    public void run() {
        while (true) {
            log.debug("=====>>>>> " +this.name);
            try {
                Thread.sleep(30);
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
        }
    }
}
